#include <cstdio>


#define NO_OIL '*'
#define OIL '@'
#define MARKED_OIL 'o'

#define MAX_M 100
#define MAX_N 100

#define MAX_NEIGHBORS 8

int m, n, oil_deposits;


inline bool get_int (int &x, int &y)
{
	scanf ("%d %d", &x, &y);
	return x > 0;
}


struct Point
{
	int x, y;

	inline bool is_invalid () {
		return x < 0 || y < 0 || x >= m || y >= n;
	}

	inline void operator += (const Point &p) {
		x += p.x;
		y += p.y;
	}
};

struct Map
{
	int m[MAX_M][MAX_N];

	inline int & operator [] (const Point &p) {
		return m[p.x][p.y];
	}
};


Map map;

const Point neighbor[MAX_NEIGHBORS] = {
	{-1, -1},
	{ 0, -1},
	{ 1, -1},
	{-1,  0},
	{ 1,  0},
	{-1,  1},
	{ 0,  1},
	{ 1,  1}
};


void fill_oil (const Point &p)
{
	Point p_aux;

	map[p] = MARKED_OIL;
	for (int i = 0; i < MAX_NEIGHBORS; ++i)
	{
		p_aux = p;
		p_aux += neighbor[i];
		if (p_aux.is_invalid ())
			continue;
		if (map[p_aux] == OIL)
			fill_oil (p_aux);
	}
}


inline void reset ()
{
	oil_deposits = 0;
}


int main ()
{
	Point p;

	while (get_int (m, n))
	{
		reset ();

		for (p.x = 0; p.x < m; ++p.x)
		{
			getchar ();
			for (p.y = 0; p.y < n; ++p.y)
			{
				map[p] = getchar ();
			}
		}

		for (p.x = 0; p.x < m; ++p.x)
		{
			for (p.y = 0; p.y < n; ++p.y)
			{
				if (map[p] == OIL)
				{
					++oil_deposits;
					fill_oil (p);
				}
			}
		}

		printf("%d\n", oil_deposits);
	}

	return 0;
}